#include<iostream>
#include<signal.h>

void handler(int sig)
{
    std::cout << "hello signal" << std::endl;
    while(true)
    {
        sigset_t pending;
        sigpending(&pending);//用于获取当前被阻塞未处理的信号集
        for(int signo = 31; signo >= 1; signo--)
        {
            if(sigismember(&pending,signo))
                printf("1");
            else
                printf("0");
        }
        std::cout << std::endl;
        sleep(1);
    }
}

int main()
{
    struct sigaction act,oact;

    act.sa_handler = handler;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask, 3);
    sigaddset(&act.sa_mask, 4);
    act.sa_flags = 0;

    sigaction(SIGINT, &act, &oact);

    while(true)
    {
        std::cout << "hello world:" << getpid() << std::endl;
        sleep(1);;
    }

    return 0;
}